#include "RenderInstance.h"

// Default Constructor - Initialize data members to default, safe, values
RenderInstance::RenderInstance(void)
{
	m_nShaderID	= -1;
	m_nTextureID = -1;
	m_nMeshID = -1;
	D3DXMatrixIdentity(&m_Transform);
}

// Constructor with params - Initialize data members according to the passed in parameters
RenderInstance::RenderInstance(int shaderID, int textureID, int meshID, float xPos, float yPos, float zPos)
{
	// Initialize context IDs
	m_nShaderID = shaderID;
	m_nTextureID = textureID;
	m_nMeshID = meshID;

	// Translate transform matrix to correct position
	D3DXMatrixTranslation(&m_Transform, xPos, yPos, zPos);
}

void RenderInstance::Translate(float x, float y, float z)
{
	D3DXMATRIX translate;
	D3DXMatrixTranslation(&translate, x, y, z);
	m_Transform *= translate;
}

void RenderInstance::Rotate(D3DXVECTOR3 axis, float angleDeg)
{
	D3DXMATRIX rotate;
	D3DXMatrixRotationAxis(&rotate, &axis, D3DXToRadian(angleDeg));
	m_Transform *= rotate;
}

void RenderInstance::ResetPosition(float x, float y, float z)
{
	D3DXMatrixTranslation(&m_Transform, x, y, z);
}

// Updates the Render Instance according to a certain behavior
void RenderInstance::Update(void)
{
	Rotate(D3DXVECTOR3(0,1,0), 1);
}